
package com.punch.common.feign.fallback;


import com.punch.common.feign.FeignStudentService;
import com.punch.common.page.PageInfo;
import com.punch.common.vo.user.student.StudentPageVO;
import com.punch.common.vo.user.student.StudentVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * 学生Service降级工场
 *
 * @author xiaol
 * @date 2019/1/18
 */

@Slf4j
@Component
public class FeignStudentServiceFallbackFactory implements FallbackFactory<FeignStudentService> {
    @Override
    public FeignStudentService create(Throwable throwable) {
        return new FeignStudentService() {

            /**
             * 根据id查询学生信息
             * @param userId 用户uid
             * @param studentId 学生id
             * @return StudentVO
             */
            @Override
            public StudentVO getFeignStudentById(Long userId, Long studentId) {
                log.error("用户{}通过学生id查找学生异常:{}", userId, studentId, throwable);
                return new StudentVO();
            }

            /**
             * 学生列表
             *  @param schoolId
             * @param studentName
             * @param currPage
             * @param pageSize
             */
            @Override
            public PageInfo<StudentPageVO> feignStudentList(Long schoolId, String studentName, Integer currPage, Integer pageSize) {
                log.error("获取学生列表异常:{}---{}", schoolId, studentName, throwable);
                return new PageInfo<>(currPage, pageSize);
            }

        };
    }

}

